package com.vm.common;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
/**
 *  该类用于获取Spring的上下文
 *  通过该类可以得到spring中所配置的bean
 *  
 * @author Fighter
 *
 */
public class SpringContext implements ApplicationContextAware{
	protected static ApplicationContext context;
	
	public void setApplicationContext(ApplicationContext applicationContext)
			throws BeansException {
		this.context=applicationContext;
	}
     /**
      * ApplicationContext对象
      * @return
      */
	 public static ApplicationContext getContext() {
	        return context;
	 }
     /**
      * 生成spring中配置的Bean对象
      * @param objectName 配置中Bean的名�?
      * @return
      */
	 public static Object generateObject(String objectName) {
	        return  SpringContext.getContext().getBean(objectName);
	 }
	 

	
	

}
